<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::post('auth/login', 'AuthController@login');

Route::group([
    'middleware' => 'auth:api',
], function () {

    Route::group([
        'prefix' => 'auth'
    ], function () {
        Route::delete('logout', 'AuthController@logout');
        Route::put('refresh', 'AuthController@refresh');
        Route::get('me', 'AuthController@me');
    });

    Route::get('username/exists', 'UserController@userExists');

    Route::group([
        'prefix' => 'account'
    ], function () {
        Route::get('clues/{account}', 'AccountController@clues');
        Route::get('signature/{account}', 'AccountController@signature');
    });

    Route::group([
        'prefix' => 'distribution'
    ], function () {
        Route::post('{user}', 'ClueDistributionController@distribution');
    });
    Route::group([
        'prefix' => 'clue'
    ], function () {
        Route::post('tag/{clue}', 'ClueController@setTag');
        Route::get('excel', 'ClueController@exportExcel');
    });
    Route::group([
        'prefix' => 'user'
    ], function () {
        Route::get('switchStatus', 'UserController@switchStatus');
        Route::get('type', 'UserController@typeUser');
        Route::post('work/{user}', 'UserController@setWork');
        Route::get('work', 'UserController@workUser');
        Route::get('clue/{user}', 'ClueController@userClue');
    });
    Route::get('workUser', 'UserController@workUser');
    Route::group([
        'prefix' => 'tag'
    ], function () {
        Route::put('{clueTag}', 'ClueTagController@update');
        Route::delete('{clueTag}', 'ClueTagController@destroy');
    });
    Route::resource('clue', 'ClueController', ['only' => ['index']]);
    Route::resource('tag', 'ClueTagController', ['only' => ['index', 'store']]);
    Route::resource('account', 'AccountController', ['only' => ['index', 'store', 'update', 'destroy']]);
    Route::resource('user', 'UserController', ['only' => ['index', 'update', 'destroy', 'store']]);
    Route::apiResource('timetable', 'TimetableController');
    Route::apiResource('permission', 'PermissionController');
    Route::apiResource('role', 'RoleController');

});
